package com.xbell.app.sys.common;

public class XbellRuntimeException extends RuntimeException{
    private static final long serialVersionUID = -1846754994136867764L;

    private ResponseCode code;
    private String msg;
    private Object data;
    private boolean needLog;

    public XbellRuntimeException(String msg,ResponseCode code,Object data){
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    public XbellRuntimeException(String msg,ResponseCode code){
        this(msg,code,null);
    }

    public Object getData(){
        return this.data;
    }
    public void setData(Object data){
        this.data = data;
    }

    /**
    * @Description: 错误码
    */
    public ResponseCode getCode() {
        return code;
    }
    /**
     * @Description: 错误码
     */
    public void setCode(ResponseCode code) {
        this.code = code;
    }
    /**
     * @Description: 错误信息
     */
    public String getMsg() {
        return msg;
    }
    /**
     * @Description: 错误信息
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * @Description: 是否需要记日志
     */
    public boolean isNeedLog() {
        return needLog;
    }
    /**
     * @Description: 是否需要记日志
     */
    public void setNeedLog(boolean needLog) {
        this.needLog = needLog;
    }
    
    /**
     * 所传参数未能匹配任何数据
     * @return
     * 2024年1月10日上午8:34:55
     * @author 王文胜
     */
    public static XbellRuntimeException noDataFoundException() {
    	XbellRuntimeException e = new XbellRuntimeException(ResponseCode.ResponseCodeParamNotFoundDataError.errmsg,ResponseCode.ResponseCodeParamNotFoundDataError,null);
    	return e;
    }
    
    /**
     * 不在时间内
     * @return
     */
    public static XbellRuntimeException notInTimeException() {
    	XbellRuntimeException e = new XbellRuntimeException("不在时间内",ResponseCode.ResponseCodeOKButNotRight,null);
    	return e;
    }
    
}
